<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/7/25
  Time: 18:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme()
            +"://"
            +request.getServerName()
            + ":"
            +request.getServerPort()
            +request.getContextPath()
            +"/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>用户管理</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/webjars/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#sub_btn").click(function () {
                var judgename = $("#judgename").val();
                var judgepassword = $("#judgepassword").val();
                var flag = true;
                if(judgename===""||judgepassword==="") {
                    $("span.errorMsg").text("评委用户名或密码不能为空！");
                    return false;
                }
            });
            $("#judgeTable a").click(function () {
                var $trObj = $(this).parent().parent();
                var name = $trObj.find("td:first").text();
                if (confirm("你确定要删除" + name + "吗？")) {
                }else {
                    return false;
                }
            });
        });
    </script>
</head>
<body>
<h1>项目有以下评委:</h1>
<form action="userServlet" method="post">
    <input type="hidden" name="action" id="action" value="addJudge"/>
<table id="judgeTable">
<c:forEach items="${sessionScope.judges}" var="entry">
    <tr>
        <td>用户名:${entry.judgename}</td>
        <td>密码:${entry.judgepassword}</td>
        <td><a href="userServlet?action=deleteJudge&judgeId=${entry.judgeId}">删除</a></td>
    </tr>
</c:forEach>
</table>
    <table>
    <tr>
        <td>添加评委</td>
        <td>
            <input type="text" placeholder="请输入评委的用户名" tabindex="1" name="judgename" id="judgename"/>
        </td>
        <td>
            <input type="text" placeholder="请输入评委的密码" tabindex="1" name="judgepassword" id="judgepassword"/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="submit" value="添加评委" id="sub_btn"/>
        </td>
    </tr>
    </table>
</form>
<a href="user/home.jsp">
    <button>完成</button>
</a>
<br>
<span class="errorMsg">${requestScope.msg}</span>
</body>
</html>
